package com.wltjack.springboot.controller;

import com.wltjack.springboot.service.EsUserService;
import com.wltjack.springboot.vo.esEntity.UserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Optional;

@RequestMapping("/es")
@RestController
public class EsController {
    @Autowired
    private EsUserService esUserService;

    @PostMapping("/addUser")
    public UserEntity addUser(@RequestBody UserEntity userEntity){
        return esUserService.addUser(userEntity);
    }

    @PostMapping("/findById")
    public Optional findById(String id){
        return esUserService.findById(id);
    }

    @PostMapping("/searchByKeyWord")
    public String searchByKeyWord(String keyWord){
        return esUserService.search(keyWord);
    }

}
